#ifndef CONTACTWIDGET_H
#define CONTACTWIDGET_H

#include <QWidget>
#include <QList>
#include <QListWidgetItem>
#include "UserLayer/GUI/ContactWidget/contactbox.h"
#include "AbstractLayer/Network/threadmanger.h"
#include "UserLayer/External/pagemanger.h"
#include "UserLayer/GUI/AddfriendWidget/addfriendwidget.h"
#include <AbstractLayer/Database/friendapplylib.h>
#include <QHash>
#include <QMenu>
#include <QAction>

namespace Ui {
class ContactWidget;
}

class ContactWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ContactWidget(QWidget *parent = nullptr);
    ~ContactWidget();
    //添加一项向好友列表中
    void addContact(const QString oc,const QString name);
    //搜索
    void searchOCName(QString);
    //右侧控件出现
    void rightShow();
    //右侧控件隐藏
    void rightHide();
    //追加联系人
    void appendContact(const QString& friendoc,const QString& friendname);
public slots:
    //添加好友库的信息到列表
    void loadFriendToUI();
private slots:

    //左侧好友列表点击
    void on_listWidget_itemClicked(QListWidgetItem *item);
    //发消息按钮点击
    void on_btn_chat_clicked();
    //搜索框文本变化，实时搜索
    void on_lineEdit_search_textEdited(const QString &arg1);

    void on_btn_else_clicked();

    //删除联系人
    void deleteContact();
    void on_btn_addfriend_clicked();

private:
    //维护左侧控件的列表，不需动
    QList<ContactBox*> contactlist;
    //哈希表为了查找
    QHash<QString,int> oclist;
    QHash<QString,int> namelist;
    QHash<QString,QString> octoname;
    QHash<QString,QString> nametooc;
    QStringList removeFriendList;
    QString removeFriendoc;

    Ui::ContactWidget *ui;
    QString currentName;
    QString currentOC;
    int currentIndex;

    bool rightIsEmpty;
    int count;
    QMenu* menu;
    AddFriendWidget* addfriendwidget;
};

#endif // CONTACTWIDGET_H
